<template>
  <div>

    <Panel title="集团大客户" useBack>
         <ModifyForm
        slot="body"
        :editColumn="editColumn"
        :temporaryData='temporaryData'
        labelWidth="150px"
        :updateData="updateData"
      >
        <p
          slot="title"
        ></p>
      </ModifyForm>
    </Panel>
  </div>
</template>
<script>
import Panel from "@/components/Panel";
import ModifyForm from "@/components/ModifyForm";
import ModalPanel from "@/components/ModalPanel";
import request from "@/tools/request";

export default {
  name:'companyInfo',
  components: {
    Panel,
    ModalPanel,
    ModifyForm
  },
  data() {
    return {
     configValue:"",
      editorOption: {},
      typeList: [],
      temporaryData: {},
      appointmentTime: null,
      appointmentTimePost: null,
      editColumn: [
        {
          name: "集团名称",
          prop: "name",
          type: "text",
          width:12,
          required: true
        },
       
         {
          name: "状态",
          prop: "state",
          type: "select",
          optionBindLabel: 'name',
          optionBindValue: 'id',
          optionList: [{'id': '','name': "请选择状态"},{'id': 1,'name': "启用"},{'id':0, 'name':"未启用"}],
          width:12,
          required: true
        },
        {
          name: "账号最高欠费金额",
          width: 12,
          prop: "maxArrears",
          type: "text",
          required: true
        },
       
        {
          name: "备注",
          width: 12,
          prop: "mark",
          type: "text",
          required: false
        },
      ],
    };
  },
  computed: {
 

  },
  methods: {
   async updateData(values) {
     const {id, name, balance, contactsPhone, mark, maxArrears, state } = values
     let url = id ? "/company/group/update": "/company/group/add"
     let msg = id ? "编辑成功" : "添加成功"
     let res = await request({
       url: url,
       method: "POST",
       data: {id, name, balance, contactsPhone, mark, maxArrears, state }
     })
     if(res.code !==0) return
      this.$message.success(msg)
      this.$router.go(-1)
    },
    async fetchData(id){
      let { groupCompany } = await request({
        url: "/company/group/info/"+id,
        method: "GET",
        data: {}
      });
      this.temporaryData = groupCompany
    }
  },
  created() {
    if(this.$route.query.id)
      this.fetchData(this.$route.query.id)
  }
};
</script>

<style lang='scss' module>

</style>